package com.example.treeHole.controller;

import com.example.treeHole.result.Result;
import com.example.treeHole.service.ArticleReplyService;
import com.example.treeHole.vo.ArticleReply;
import com.example.treeHole.vo.UserInfo;
import com.example.treeHole.vo.dto.ArticleReplyDto;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/articleReply")
public class ArticleReplyController {
    @Autowired
    private ArticleReplyService articleReplyService;

    @PostMapping("/create")
    public Result create(@RequestBody ArticleReply articleReply){
        articleReplyService.create(articleReply);
        return Result.success();
    }

    @GetMapping("/findById/{id}")
    public Result<ArticleReply> findByid(@PathVariable String id){
        ArticleReply articleReply=articleReplyService.findById(id);
        return Result.success(articleReply);
    }

    @GetMapping("/page")
    public Result<PageInfo<ArticleReply>> page(@RequestBody ArticleReplyDto articleReplyDto){
        PageInfo<ArticleReply> pageInfo = articleReplyService.page(articleReplyDto);
        return Result.success(pageInfo);
    }
}
